package com.xja.service.impl;/**
 * @className: CourseServiceImpl
 * @description: TODO 类描述
 * @author: wkx
 * @date: 2022/4/19
 **/

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xja.mapper.CourseMapper;
import com.xja.pojo.Admin;
import com.xja.pojo.BlogUsers;
import com.xja.pojo.CourseInfo;
import com.xja.service.CourseService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName : CourseServiceImpl  //类名

 * @Author : Lenovo //作者
 * @Date: 2022/4/19  17:01
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    @Transactional(readOnly = true)
    @Override
    public List<CourseInfo> getCourse(Integer page, CourseInfo course) {
        PageHelper.startPage(page,5);
        List<CourseInfo> courseInfos = courseMapper.selectCourse(course);
        PageInfo<CourseInfo> pageInfo = new PageInfo<>(courseInfos);
        pageInfo.setPageNum(page);
        return pageInfo.getList();

    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void stopCourse(Integer cid) {
        courseMapper.updateStop(cid);
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void startCourse(Integer cid) {
        courseMapper.updateStart(cid);
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void addCourse(CourseInfo course) {
        courseMapper.addCourse(course);
    }

    @Override
    public List<BlogUsers> getCoursePerson(Integer cid) {
        return courseMapper.getCoursePerson(cid);
    }
}
